import request from '@/utils/request'
import * as mock from './mock/circulation'

const isMock = import.meta.env.VITE_API_MOCK === 'true'

/**
 * 获取HDFS余额信息
 * @returns {Promise} 返回HDFS余额信息
 */
// export function getHdfsBalance() {
//   if (isMock) {
//     return Promise.resolve(mock.default['get|/api/circulation/balance'])
//   }
//   return request({
//     url: '/api/circulation/balance',
//     method: 'get'
//   })
// }

/**
 * 获取可兑换币种列表
 * @returns {Promise} 返回可兑换币种列表
 */
export function getExchangeCurrencies() {
  if (isMock) {
    return Promise.resolve(mock.default['get|/api/circulation/currencies'])
  }
  return request({
    url: '/cfg/exchange',
    method: 'get'
  })
}

/**
 * 获取流通统计数据
 * @returns {Promise} 返回流通统计数据
 */
export function getCirculationStats() {
  if (isMock) {
    return Promise.resolve(mock.default['get|/api/circulation/stats'])
  }
  return request({
    url: '/exchange/stats',
    method: 'get'
  })
}

/**
 * 获取7天流通走势数据
 * @returns {Promise} 返回7天流通走势数据
 */
export function getWeeklyTrend() {
  if (isMock) {
    return Promise.resolve(mock.default['get|/api/circulation/trend'])
  }
  return request({
    url: '/exchange/weekly',
    method: 'get'
  })
}

/**
 * 创建贡献订单
 * @param {Object} data 订单数据
 * @returns {Promise}
 */
export function exchangeContributo(data) {
  return request({
    url: '/exchange/contributor',
    method: 'post',
    data
  })
}


/**
 * 贡献记录
 * @returns {Promise} 返回7天流通走势数据
 */
export function contributorList(data) {
  return request({
    url: '/exchange/contributorList',
    method: 'get',
    data
  })
}
